package com.example.springai.controller;

import com.example.springai.service.RagService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/rag")
public class RagController {

    private final RagService ragService;

    public RagController(RagService ragService){
        this.ragService = ragService;
    }

    @PostMapping("/txt")
    public ResponseEntity<Void> txt(@RequestBody Map<String,String> txt) {
        ragService.load(txt.get("txt"));
        return ResponseEntity.ok().build();
    }
}
